﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Mr.Data.Entities;
using Mr.Data.DBContext;
namespace TestSqlSurging.Controllers
{
    public class HomeController : BaseController
    {
        public ActionResult Index()
        {
            return View();
        }
        [HttpGet,AllowAnonymous]
        public JsonResult GetUsers()
        {
            var dbContext = new DbContext<Users>();
            var data = dbContext.DbClient.GetList();
            dbContext.Db.Ado.UseTran(() =>
            {
                dbContext.DbClient.Insert(new Users
                {
                    Age = 1,
                    CityId = 1,
                    Gender = 0,
                    Name = "xman0111",
                    NotMapped = 1,
                    OpTime = DateTime.Now,
                });
            });
            return Json(data, JsonRequestBehavior.AllowGet);
        }
        [HttpGet]
        public JsonResult CreateEntity()
        {
            Mr.Data.AutoCreateEntity.initDBEntity();
            return Json("", JsonRequestBehavior.AllowGet);
        }
        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

    }
}